package com.zlw.json.controller;

import com.zlw.json.vo.ResultVO;
import com.zlw.json.vo.StudentObj;
import com.zlw.json.vo.TestObj;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @ClassName TestController
 * @Description TODO
 * @Author zhaoluowei
 * @Date 2020/2/3  21:06
 * @Version 1.0
 */
@Slf4j
@RestController
@RequestMapping(value = "/test")
public class TestController {

    @GetMapping(value = "/list")
    public ResultVO list() {
        log.info(" ====== 测试 ====== 进入 ");
        //好像会自动过滤  为 null的属性
        ResultVO<TestObj> resultVO = new ResultVO<TestObj>();
        try {
            resultVO.setCode(0).setMsg("查询成功");
            TestObj testObj = new TestObj();
            testObj.setUsername("123")
                    .setPassword("456")
                    .setDate_one(new Date())
                    .setDate_two(new Date());

            List<StudentObj> studentObjs = new ArrayList<>();
            studentObjs.clear();

            StudentObj studentObj = new StudentObj();
            studentObj.setName("张三").setAge(18).setScore(100);

            StudentObj studentObj2 = new StudentObj();
            studentObj2.setName("李四").setAge(25);
            studentObjs.add(studentObj);
            studentObjs.add(studentObj2);
            testObj.setStudentObjList(studentObjs);


            resultVO.setData(testObj);

        } catch (Exception e) {
            e.printStackTrace();
        }
        log.info(" ====== 测试 ====== 离开 ");
        return resultVO;
    }


}
